var uid = 0;
export default class Dep {
    constructor() {
        this.id = uid++;
        //用数组存储自己的订阅者.放的是watcher的实例
        this.subs = [];
    }
    addSub(sub) {
        this.subs.push(sub);
    }
    //添加依赖
    depend() {
        //Dep.target：就是自己指定的全局的位置而已，只要是全局唯一即可
        if (Dep.target) {
            this.addSub(Dep.target);
        }
    }
    notify() {
        const subs = this.subs.slice();//浅克隆一份
        for (let i = 0; i < subs.length; i++) {
            subs[i].update();
        }
    }
}